package com.ruoyi.web.controller.stock;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.StockLtFootman;
import com.ruoyi.system.service.IStockLtFootmanService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 龙头小弟库Controller
 * 
 * @author ruoyi
 * @date 2024-02-26
 */
@RestController
@RequestMapping("/stock/footman")
public class StockLtFootmanController extends BaseController
{
    @Autowired
    private IStockLtFootmanService stockLtFootmanService;

    /**
     * 查询龙头小弟库列表
     */
    @PreAuthorize("@ss.hasPermi('stock:footman:list')")
    @GetMapping("/list")
    public TableDataInfo list(StockLtFootman stockLtFootman)
    {
        startPage();
        List<StockLtFootman> list = stockLtFootmanService.selectStockLtFootmanList(stockLtFootman);
        return getDataTable(list);
    }

    /**
     * 导出龙头小弟库列表
     */
    @PreAuthorize("@ss.hasPermi('stock:footman:export')")
    @Log(title = "龙头小弟库", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, StockLtFootman stockLtFootman)
    {
        List<StockLtFootman> list = stockLtFootmanService.selectStockLtFootmanList(stockLtFootman);
        ExcelUtil<StockLtFootman> util = new ExcelUtil<StockLtFootman>(StockLtFootman.class);
        util.exportExcel(response, list, "龙头小弟库数据");
    }

    /**
     * 获取龙头小弟库详细信息
     */
    @PreAuthorize("@ss.hasPermi('stock:footman:query')")
    @GetMapping(value = "/{recordId}")
    public AjaxResult getInfo(@PathVariable("recordId") Long recordId)
    {
        return success(stockLtFootmanService.selectStockLtFootmanByRecordId(recordId));
    }

    /**
     * 新增龙头小弟库
     */
    @PreAuthorize("@ss.hasPermi('stock:footman:add')")
    @Log(title = "龙头小弟库", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody StockLtFootman stockLtFootman)
    {
        return toAjax(stockLtFootmanService.insertStockLtFootman(stockLtFootman));
    }

    /**
     * 修改龙头小弟库
     */
    @PreAuthorize("@ss.hasPermi('stock:footman:edit')")
    @Log(title = "龙头小弟库", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody StockLtFootman stockLtFootman)
    {
        return toAjax(stockLtFootmanService.updateStockLtFootman(stockLtFootman));
    }

    /**
     * 删除龙头小弟库
     */
    @PreAuthorize("@ss.hasPermi('stock:footman:remove')")
    @Log(title = "龙头小弟库", businessType = BusinessType.DELETE)
	@DeleteMapping("/{recordIds}")
    public AjaxResult remove(@PathVariable Long[] recordIds)
    {
        return toAjax(stockLtFootmanService.deleteStockLtFootmanByRecordIds(recordIds));
    }
}
